// 1.  定义一个Promise构造函数，传入`excutor`执行器函数
// 2. 在构造函数内定义2个属性
//    1. `this.PromiseState` 保存promise状态
//    2. `this.PromiseResult`保存promise结果值
// 3. 定义resolve、reject函数
//    1. 在resolve函数内修改`this.PromiseState` 为`fulfilled`，`this.PromiseResult`为value
//    2. 在reject函数内修改`this.PromiseState`为 `rejected`,`this.PromiseResult` 为 reason
// 4. 调用`excutor`函数并传入resolve、reject函数
// 5. try捕获执行`excutor`函数时抛出错误
//    1. catch 内调用reject函数并传入err参数

function Promise(excutor){
    this.PromiseState = 'pending'; 
    this.PromiseResult = undefined;

    // 定义
    let resolveFn = (value)=>{
        this.PromiseState = 'fulfilled';
        this.PromiseResult = value;
    }

    let rejectFn = (reason)=>{
        this.PromiseState = 'rejected';
        this.PromiseResult = reason;
    }

    try {
        excutor(resolveFn,rejectFn)
    } catch (error) {
        rejectFn(error)
    }
}